package cn.iocoder.yudao.module.resource.dal.mysql.usertimebalance;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.resource.controller.admin.usertimebalance.vo.UserTimeBalancePageReqVO;
import cn.iocoder.yudao.module.resource.dal.dataobject.usertimebalance.UserTimeBalanceDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户时长余额 Mapper
 *
 * @author lizhongwen
 */
@Mapper
public interface UserTimeBalanceMapper extends BaseMapperX<UserTimeBalanceDO> {

    default PageResult<UserTimeBalanceDO> selectPage(UserTimeBalancePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserTimeBalanceDO>()
                .eqIfPresent(UserTimeBalanceDO::getId, reqVO.getId())
                .eqIfPresent(UserTimeBalanceDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(UserTimeBalanceDO::getTotalTimeMs, reqVO.getTotalTimeMs())
                .betweenIfPresent(UserTimeBalanceDO::getRemainingTimeMs, reqVO.getRemainingTimeMs())
                .betweenIfPresent(UserTimeBalanceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserTimeBalanceDO::getId));
    }

}